package com.pkk.cloud.support.admin.mybatis.client;

import com.pkk.cloud.support.admin.dto.req.client.OauthClientPageReqDto;
import com.pkk.cloud.support.admin.dto.resp.client.OauthClientDetailRespDto;
import com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient;
import com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClientScope;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * @description: 客户端与scope的持久层
 * @author: peikunkun
 * @create: 2020-03-30 15:50
 **/
@Mapper
public interface PenguinSysClientScopeBusinessMapper {


  /**
   * @Description: 保存服务客户端操作
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:00
   */
  int savePenguinOauthClient(PenguinOauthClient record);

  /**
   * @Description: 获取客户端信息依据id
   * @Param: id
   * @return: com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:01
   */
  PenguinOauthClient selectPenguinOauthClientById(Integer id);

  /**
   * @Description: 更具id更新客户端信息
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:02
   */
  int updatePenguinOauthClientById(PenguinOauthClient record);

  /**
   * @Description: 验证是否存在客户端
   * @Param: clientType
   * @Param clientId
   * @Param ownServerId
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 上午 11:33
   */
  int countClientExists(HashMap<String, Object> condition);

  //**************************************业务分割线******************************************

  /**
   * @Description: 保存客户端授权scope信息
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:10
   */
  int insertPenguinOauthClientScope(PenguinOauthClientScope record);

  /**
   * @Description: 依据id查询客户端的授权范围的信息
   * @Param: id
   * @return: com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClientScope
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:10
   */
  PenguinOauthClientScope selectPenguinOauthClientScopeById(Long id);

  /**
   * @Description: 更新授权范围的信息依据id
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:11
   */
  int updatePenguinOauthClientScopeById(PenguinOauthClientScope record);


  /**
   * @Description: 分页查询客户/访问客户端的信息
   * @Param: body
   * @return: java.util.List<com.pkk.cloud.support.admin.dto.resp.client.OauthClientPageRespDto>
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 下午 4:18
   */
  List<OauthClientDetailRespDto> findOauthClientPage(OauthClientPageReqDto body);

  /**
   * @Description: 删除客户端依据id
   * @Param: ids
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/4/1 0001 下午 4:07
   */
  int updateOauthClientCloseById(@Param("ids") Long[] ids, @Param("userId") String userId,
      @Param("operateDate") Date operateDate);

  /**
   * @Description: 获取客户端信息依据id
   * @Param: id
   * @return: com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient
   * @Author: peikunkun
   * @Date: 2020/4/2 0002 下午 1:49
   */
  PenguinOauthClient getOauthClientById(Long id);

  /**
   * @Description: 获取所有的客户端
   * @Param:
   * @return: java.util.List<com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient>
   * @Author: peikunkun
   * @Date: 2020/4/8 下午9:47
   */
  List<PenguinOauthClient> findAllClientView();

  /**
   * @Description: 依据用户id获取用户客户端详情
   * @Param: userId
   * @return: java.util.List<com.pkk.cloud.support.oauth2.client.detail.client.entity.PenguinOauthClient>
   * @Author: peikunkun
   * @Date: 2020/4/8 下午9:57
   */
  List<PenguinOauthClient> findUserClientView(Long userId);

  /**
   * @Description: 获取客户端的授权对象
   * @Param: clientId
   * @return: java.util.Set<java.lang.String>
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 4:42
   */
  Set<String> findClientScopeByClientId(String clientId);

  /**
   * @Description: 删除客户端的绑定信息依据客户端信息
   * @Param: clientId
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 5:26
   */
  int deleteClientScopeByClientId(String clientId);

  /**
   * @Description: 批量保存处理客户端的授权对象
   * @Param: clientId
   * @Param scope
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 5:32
   */
  int batchSaveClientScope(@Param("clientId") String clientId, @Param("scopes") Set<String> scopes);
}
